
uniform float speed;
uniform vec4 color;

vec3 hsv2rgb(float h, float s, float v)
{
  vec4 t = vec4(1.0, 2.0/3.0, 1.0/3.0, 3.0);
  vec3 p = abs(fract(vec3(h) + t.xyz) * 6.0 - vec3(t.w));
  return v * mix(vec3(t.x), clamp(p - vec3(t.x), 0.0, 1.0), s);
}

czm_material czm_getMaterial(czm_materialInput materialInput){
  czm_material material = czm_getDefaultMaterial(materialInput);
  vec2 v_st = materialInput.st; // 获取uv坐标
  float iTime = czm_frameNumber  * speed / 100.0;
  vec2 pos = (v_st.xy * 2.0 - v_st.xy) * v_st ;

  float h = mix(0.5, 0.65, length(pos));
  vec4 color1 = vec4(hsv2rgb(h, 1.0, 1.0), 1.0);
  float radius = 0.05;
  float width = 0.8;
  float power = 0.1;
  float dist1 = length(pos);
  dist1 = fract((dist1 * 5.0) - fract(iTime));
  float dist2 = dist1 - radius;
  float intensity = pow(radius / abs(dist2), width); 
  vec3 finalColor = color1.rgb * intensity * power * max((0.8- abs(dist2)), 0.0);
  pos = abs(pos);

  material.alpha = pow(intensity , 3.0);
  material.diffuse = color.rgb * intensity;
  return material;
}